package com.guigu.liuyunan.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.liuyunan.pojo.LYNPageVo;
import com.guigu.liuyunan.pojo.Order;
import com.guigu.liuyunan.service.OrederService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("LYN")
public class OrderController {

    @Autowired
    OrederService os;


    @PostMapping("orderInfo")
    public PageInfo<Order> OrderInfo(@RequestBody LYNPageVo pageVo){
        if (pageVo.getName()!=null){
            pageVo.setName(pageVo.getName().trim());
        }
        return os.OrderInfo(pageVo);
    }

    @PostMapping("orderUp")
    public int orderUp(@RequestBody Order order){
        return os.orderUp(order);
    }

    @PostMapping("orderQX")
    public int orderQX(@RequestBody Order order){
        return os.orderQX(order);
    }

    @PostMapping("orderAdd")
    public int orderAdd(@RequestBody Order orderAdd){
      String date=orderAdd.getOrderdate().substring(0,8);
      Integer day=Integer.parseInt(orderAdd.getOrderdate().substring(8,10))+1;
     orderAdd.setOrderdate(date+day.toString());
        return os.orderAdd(orderAdd);
    }


    @RequestMapping("kaihytjcha")
    public List<Order> kaihytjcha(@RequestParam(defaultValue = "2000-01") String startYear2,
                                  @RequestParam(defaultValue = "2020-01") String endYear2) {
        return os.tanhytjcha(startYear2, endYear2);
    }

    @RequestMapping("tkhytjcha")
    public List<Order> tkhytjcha(@RequestParam(defaultValue = "2000-01") String startYear2,
                                 @RequestParam(defaultValue = "2020-01") String endYear2) {
        return os.tkhytjcha(startYear2, endYear2);
    }

}
